package com.hm.health.entity.dao;

import org.litepal.crud.DataSupport;

public class EcgPatchSectorInfo extends DataSupport {

    // 对应于flash的sector id;
    private int sectorId;

    // 该sector里面包含frame总数
    private int totalFrameNum;

    // 该sector开始时间
    private long beginTimeStamp;

    // 该sector最后一帧的时间
    private long endTimeStamp;

    // sector数据存储路径
    private String sectorFilePath;

    private String sectorResultFilePath;
    // 测试者id
    private String testId;

    // 是否重组过csv了，重组后，会将对应存储的数据删除
    private boolean isRegroupCSV;

    // 在线或者离线模式
    private int mode;

    private int eventType;

    private boolean isValid;

    public int getSectorId() {
        return sectorId;
    }

    public void setSectorId(int sectorId) {
        this.sectorId = sectorId;
    }

    public int getTotalFrameNum() {
        return totalFrameNum;
    }

    public void setTotalFrameNum(int totalFrameNum) {
        this.totalFrameNum = totalFrameNum;
    }

    public long getBeginTimeStamp() {
        return beginTimeStamp;
    }

    public void setBeginTimeStamp(long beginTimeStamp) {
        this.beginTimeStamp = beginTimeStamp;
    }

    public long getEndTimeStamp() {
        return endTimeStamp;
    }

    public void setEndTimeStamp(long endTimeStamp) {
        this.endTimeStamp = endTimeStamp;
    }

    public String getSectorFilePath() {
        return sectorFilePath;
    }

    public void setSectorFilePath(String sectorFilePath) {
        this.sectorFilePath = sectorFilePath;
    }

    public String getTestId() {
        return testId;
    }

    public void setTestId(String testId) {
        this.testId = testId;
    }

    public boolean isRegroupCSV() {
        return isRegroupCSV;
    }

    public void setRegroupCSV(boolean regroupCSV) {
        isRegroupCSV = regroupCSV;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public int getEventType() {
        return eventType;
    }

    public void setEventType(int eventType) {
        this.eventType = eventType;
    }

    public String getSectorResultFilePath() {
        return sectorResultFilePath;
    }

    public void setSectorResultFilePath(String sectorResultFilePath) {
        this.sectorResultFilePath = sectorResultFilePath;
    }

    public boolean hasAlgoResult() {
        int online_offline_mode = mode & 0xff;
        int mcu_app_mode = (mode & 0xff00) >> 8;

        if (mcu_app_mode == 1) {
            // app mode
            return true;
        } else if (mcu_app_mode == 0) {
            // not set
            return true;
        } else if (mcu_app_mode == 2) {
            // mcu mode
            if (online_offline_mode == 0) {
                // offline mode
                return false;
            } else {
                // online mode
                return true;
            }
        }

        return false;
    }

    public boolean isValid() {
        return isValid;
    }

    public void setValid(boolean valid) {
        isValid = valid;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("EcgPatchSectorInfo:{sectorId:").append(sectorId)
                .append(", totalFrameNum:").append(totalFrameNum)
                .append(", beginTimeStamp:").append(beginTimeStamp)
                .append(", endTimeStamp:").append(endTimeStamp)
                .append(", testId:").append(testId)
                .append(", mode:").append(mode)
                .append(", isRegroupCsv:").append(isRegroupCSV)
                .append(", event type:").append(eventType)
                .append(", isValid:").append(isValid).append("}");
        return builder.toString();
    }
}
